﻿using CMS.Models;
using CMS.ViewModel;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CMS.Windows
{
    /// <summary>
    /// OutputCargoWindow.xaml 的交互逻辑
    /// </summary>
    public partial class OutputCargoWindow : MetroWindow
    {
        public OutputCargoWindow()
        {
            InitializeComponent();
            Loaded += (s, e) =>
            {
                var vm = DataContext as OutputCargoViewModel;
                if (null == vm) return;
                var list = new RecordProvider().Select();
                if(null == list) return;
                var inputCount = list.FindAll(item => item.RecordType == true).Sum(item => item.Number);
                var outputCount = list.FindAll(item => item.RecordType == false).Sum(item => item.Number);
                var sum = inputCount - outputCount;
                vm.Sum=sum;
            };
        }



    }
}
